package com.minelx.datamicroscope.querylanguage.data.sql;

import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
import com.minelx.datamicroscope.querylanguage.data.CollectingKey;

import java.util.Collections;

import static com.minelx.datamicroscope.querylanguage.data.QueryBuilder.strip;

public class ContentAliasedTablesFulfill implements AliasedTablesFulfil {

	private final SQLExprTableSource fromTableSource;

	public ContentAliasedTablesFulfill(SQLExprTableSource fromTableSource) {
		this.fromTableSource = fromTableSource;
	}

	@Override
	public void fulfil(AliasedTablesBuilder aliasedTablesBuilder) {
		CollectingKey tableKey = new CollectingKey(
				strip(fromTableSource.getTableName(), "`"),
				Collections.emptyMap(),
				Collections.emptyList());
		aliasedTablesBuilder.markAliasedTable(fromTableSource.getAlias(), tableKey, "right");
	}
}
